<!--#include file="../nav/admin_top.php" -->  
<script type="text/javascript">
var url_save = '<?=url::build('admin_vege','add',array('reqtype'=>'json'))?>'; 
var url_return = '<?=url::build('admin_vege','index')?>';   
var types = <?=json_encode($types)?>;
$().ready(function(){  
	showLoading();   
  $('#code').focus();
	  fnTypePriceDft();
});
/* 保存 */
function fnSave(){
	var $price = $('#price').val();
	
	if(! fnRegExp('reg_num1',$price) ){
	
		alert('请填写正确的【菜品单价】');
		$('#price').focus();
		return false;
	}
	if(! fnRegExp('reg_num1',$('#pack').val()) ){
	
		alert('请填写正确的【包装规格】');
		$('#pack').focus();
		return false;
	}
	
	if($('#code').val() == ''){
		alert('请填写【菜品编号】');
		$('#code').focus();
		return false;
	}
	if($('#name').val() == ''){
		alert('请填写【菜品名称】');
		$('#name').focus();
		return false;
	}
	return true;
}

function fnTypePriceDft(){
	var obj = types[$('#type_id').val()];
		$('#price').val(obj.price);
		$('#pack').val(obj.pack);
}
</script>
<div class="titleDiv">
	<div class="titleCaption">
		<span class="captionSpan">菜品管理 - 添加菜品</span>
		<span class="totalSpan"> <label id="captionNum"></label> </span>
	</div>
</div>
<form id="myform" action="" method="post" enctype="multipart/form-data"  onsubmit="return fnSave();">
<div class="blockdiv">
	<div class="titlediv">基本信息</div>
	<table class="mytable" > 
		<tr>
			<td class="mylabel"><span class="red">*</span>菜品品牌：</td>
			<td class="myinfo" > 
				<select id="logo_id" name="logo_id" class="textBox"  > 
					<?PHP
					foreach($logos as $val){ 
						echo '<option value="'.$val['id'].'">'.$val['logo_name'].'</option>'; 
					}
					?> 
				</select>
			</td>  
		</tr>
		<tr>
			<td class="mylabel"><span class="red">*</span>菜品类别：</td>
			<td class="myinfo" > 
				<select id="type_id" name="type_id" class="textBox" onchange="fnTypePriceDft()"  > 
					<?PHP
					foreach($types as $val){ 
						echo '<option value="'.$val['id'].'">'.$val['type_name'].'</option>'; 
					}
					?> 
				</select>
			</td>  
		</tr> 
		<tr>
			<td class="mylabel"><span class="red">*</span>菜品编号：</td>
			<td class="myinfo" > 
				<input type="text" class="textBox" id="code" name="code" maxlength="100" style="width:80%" />
			</td>  
		</tr> 
		<tr>
			<td class="mylabel"><span class="red">*</span>菜品名称：</td>
			<td class="myinfo" > 
				<input type="text" class="textBox" id="name" name="name" maxlength="100" style="width:80%" />
			</td>  
		</tr> 
		<tr>
			<td class="mylabel"><span class="red">*</span>菜品单价：</td>
			<td class="myinfo" > 
				<input type="text" class="textBox" id="price" name="price" maxlength="8" style="width:80px;text-align:right" /> 元
			</td>  
		</tr> 
		<tr>
			<td class="mylabel"><span class="red">*</span>包装规格：</td>
			<td class="myinfo" > 
				<input type="text" class="textBox" id="pack" name="pack" maxlength="8" style="width:80px;text-align:right" /> KG/份
			</td>  
		</tr> 
		<tr>
			<td class="mylabel">最大可选份数：</td>
			<td class="myinfo" > 
				<select class="textBox" name="maxnum" id="maxnum">
					<option value="0">无限制</option>
					<?PHP
					for($i=1; $i<=20; $i++){
						echo '<option value="'.$i.'">'.$i.'份</option>';
					}
					?>
				</select>
				<span class="gray">该菜品作为配送计划中的可选菜品时，用户最多选取的数量</span>
			</td>  
		</tr> 
		<tr>
			<td class="mylabel">说明：</td>
			<td class="myinfo" >
				<textarea class="textBox" id="remark" name="remark" style="width:80%;height:100px;"></textarea>   
			</td>  
		</tr>
		<tr>
			<td class="mylabel">状态：</td>
			<td class="myinfo" >
				<select id="sale" name="sale" class="textBox">
					<option value="1">当季供应</option>
					<option value="0">非当季供应</option>
				</select>
			</td>
		</tr>
		<tr>
			<td class="mylabel">缩略图：</td>
			<td class="myinfo" >
				<input type="file" id="pic" name="pic" /> 
			  <span class="red">（高宽比例 3:4）</span>
			</td>  
		</tr> 
	</table> 
</div>
<div  class="button_div">
		<input type="submit" value="保 存" />
		<span class="gray">或</span> 
		<button class=" " onclick="jumpTo(url_return);return false;">返 回</button>
</div>  
</form>		
<!--#include file="../nav/admin_bottom.php" -->